package chapter_22_state.classic.client;

import chapter_22_state.classic.context.Context;
import chapter_22_state.classic.state.ConcreateState1;
import chapter_22_state.classic.state.ConcreateState2;
import chapter_22_state.classic.state.State;

/**
 * Created by yao on 2016/10/11.
 */
public class Client {
    public static void main(String[] args) {
        //创建状态
        State sate = new ConcreateState1();
        //创建环境
        Context context = new Context();
        //将状态设置到环境中
        context.setCurrentState(Context.STATE2);

        //请求
        context.handle1("A-handle1");
        context.handle2("A-handle2");

        /*//很方便的切换到了ConcreateStateB
        context.setCurrentState(new ConcreateState2());
        context.handle1("B-handle1");
        context.handle2("B-handle2");*/
    }
}
